package com.jeespring.designpattern.abstractfactory;

/**
 * @Title: AbstractFactoryPattern
 * @Description:
 * @Author 张朝阳
 * @Date 2021/1/3 15:33
 */
public class AbstractFactoryPattern {
    public static void main(String[] args) {

        //获取水果工厂
        AbstractFactory fruitFactory = Factory.getFactory("水果");

        //生产苹果
        Fruit fruit = fruitFactory.getFruit("苹果");
        fruit.produce();

        //生产香蕉
        Fruit banana = fruitFactory.getFruit("香蕉");
        banana.produce();

        //获取蔬菜工厂
        AbstractFactory vegetableFactory = Factory.getFactory("蔬菜");

        //生产西红柿
        Vegetable tomato = vegetableFactory.getVegetable("西红柿");
        tomato.produce();

        //生产土豆
        Vegetable potato = vegetableFactory.getVegetable("土豆");
        potato.produce();
    }
}
